﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Project.dalSql;
using WISD.Common;
using WISD.DBUtility.DBOperate;

namespace WISD.CarFriend.BLL.OA
{
    public class EmployeeModule
    {
        #region MaticCode

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string EmployeeID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_CF_OA_Employee");
            strSql.Append(" where EmployeeID=@EmployeeID ");
            SqlParameter[] parameters = {
					new SqlParameter("@EmployeeID", SqlDbType.NVarChar,50)			};
            parameters[0].Value = EmployeeID;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WISD.CarFriend.Model.CFModel.T_CF_OA_Employee model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_CF_OA_Employee(");
            strSql.Append("EmployeeID,Name,Sex,EmployeeImage,Birthday,IdentityCard,IdentityCardImage,Class,Position,Memo,Company,IsDisabled,MobileTel,QQ,Email,Reviser,ReviseDate,Education,School,Political,FamilyAddress,PresentAddress,HomePhone,EducationalBackground,FamilyMember,WorkExperience,Memo1,Memo2,Memo3,Memo4,Memo5,Memo6,Memo7,Memo8)");
            strSql.Append(" values (");
            strSql.Append("@EmployeeID,@Name,@Sex,@EmployeeImage,@Birthday,@IdentityCard,@IdentityCardImage,@Class,@Position,@Memo,@Company,@IsDisabled,@MobileTel,@QQ,@Email,@Reviser,@ReviseDate,@Education,@School,@Political,@FamilyAddress,@PresentAddress,@HomePhone,@EducationalBackground,@FamilyMember,@WorkExperience,@Memo1,@Memo2,@Memo3,@Memo4,@Memo5,@Memo6,@Memo7,@Memo8)");
            SqlParameter[] parameters = {
					new SqlParameter("@EmployeeID", SqlDbType.NVarChar,50),
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@Sex", SqlDbType.Int,4),
					new SqlParameter("@EmployeeImage", SqlDbType.NVarChar,100),
					new SqlParameter("@Birthday", SqlDbType.DateTime),
					new SqlParameter("@IdentityCard", SqlDbType.NVarChar,50),
					new SqlParameter("@IdentityCardImage", SqlDbType.NVarChar,100),
					new SqlParameter("@Class", SqlDbType.Int,4),
					new SqlParameter("@Position", SqlDbType.Int,4),
					new SqlParameter("@Memo", SqlDbType.NVarChar,500),
					new SqlParameter("@Company", SqlDbType.Int,4),
					new SqlParameter("@IsDisabled", SqlDbType.Int,4),
					new SqlParameter("@MobileTel", SqlDbType.NVarChar,50),
					new SqlParameter("@QQ", SqlDbType.NVarChar,50),
					new SqlParameter("@Email", SqlDbType.NVarChar,50),
					new SqlParameter("@Reviser", SqlDbType.NVarChar,50),
					new SqlParameter("@ReviseDate", SqlDbType.DateTime),
					new SqlParameter("@Education", SqlDbType.NVarChar,50),
					new SqlParameter("@School", SqlDbType.NVarChar,50),
					new SqlParameter("@Political", SqlDbType.NVarChar,50),
					new SqlParameter("@FamilyAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@PresentAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@HomePhone", SqlDbType.NVarChar,50),
					new SqlParameter("@EducationalBackground", SqlDbType.NVarChar),
					new SqlParameter("@FamilyMember", SqlDbType.NVarChar),
					new SqlParameter("@WorkExperience", SqlDbType.NVarChar),
					new SqlParameter("@Memo1", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo2", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo3", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo4", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo5", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo6", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo7", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo8", SqlDbType.NVarChar,100)};
            parameters[0].Value = model.EmployeeID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Sex;
            parameters[3].Value = model.EmployeeImage;
            parameters[4].Value = model.Birthday;
            parameters[5].Value = model.IdentityCard;
            parameters[6].Value = model.IdentityCardImage;
            parameters[7].Value = model.Class;
            parameters[8].Value = model.Position;
            parameters[9].Value = model.Memo;
            parameters[10].Value = model.Company;
            parameters[11].Value = model.IsDisabled;
            parameters[12].Value = model.MobileTel;
            parameters[13].Value = model.QQ;
            parameters[14].Value = model.Email;
            parameters[15].Value = model.Reviser;
            parameters[16].Value = model.ReviseDate;
            parameters[17].Value = model.Education;
            parameters[18].Value = model.School;
            parameters[19].Value = model.Political;
            parameters[20].Value = model.FamilyAddress;
            parameters[21].Value = model.PresentAddress;
            parameters[22].Value = model.HomePhone;
            parameters[23].Value = model.EducationalBackground;
            parameters[24].Value = model.FamilyMember;
            parameters[25].Value = model.WorkExperience;
            parameters[26].Value = model.Memo1;
            parameters[27].Value = model.Memo2;
            parameters[28].Value = model.Memo3;
            parameters[29].Value = model.Memo4;
            parameters[30].Value = model.Memo5;
            parameters[31].Value = model.Memo6;
            parameters[32].Value = model.Memo7;
            parameters[33].Value = model.Memo8;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WISD.CarFriend.Model.CFModel.T_CF_OA_Employee model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_CF_OA_Employee set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("EmployeeImage=@EmployeeImage,");
            strSql.Append("Birthday=@Birthday,");
            strSql.Append("IdentityCard=@IdentityCard,");
            strSql.Append("IdentityCardImage=@IdentityCardImage,");
            strSql.Append("Class=@Class,");
            strSql.Append("Position=@Position,");
            strSql.Append("Memo=@Memo,");
            strSql.Append("Company=@Company,");
            strSql.Append("IsDisabled=@IsDisabled,");
            strSql.Append("MobileTel=@MobileTel,");
            strSql.Append("QQ=@QQ,");
            strSql.Append("Email=@Email,");
            strSql.Append("Reviser=@Reviser,");
            strSql.Append("ReviseDate=@ReviseDate,");
            strSql.Append("Education=@Education,");
            strSql.Append("School=@School,");
            strSql.Append("Political=@Political,");
            strSql.Append("FamilyAddress=@FamilyAddress,");
            strSql.Append("PresentAddress=@PresentAddress,");
            strSql.Append("HomePhone=@HomePhone,");
            strSql.Append("EducationalBackground=@EducationalBackground,");
            strSql.Append("FamilyMember=@FamilyMember,");
            strSql.Append("WorkExperience=@WorkExperience,");
            strSql.Append("Memo1=@Memo1,");
            strSql.Append("Memo2=@Memo2,");
            strSql.Append("Memo3=@Memo3,");
            strSql.Append("Memo4=@Memo4,");
            strSql.Append("Memo5=@Memo5,");
            strSql.Append("Memo6=@Memo6,");
            strSql.Append("Memo7=@Memo7,");
            strSql.Append("Memo8=@Memo8");
            strSql.Append(" where EmployeeID=@EmployeeID ");
            SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@Sex", SqlDbType.Int,4),
					new SqlParameter("@EmployeeImage", SqlDbType.NVarChar,100),
					new SqlParameter("@Birthday", SqlDbType.DateTime),
					new SqlParameter("@IdentityCard", SqlDbType.NVarChar,50),
					new SqlParameter("@IdentityCardImage", SqlDbType.NVarChar,100),
					new SqlParameter("@Class", SqlDbType.Int,4),
					new SqlParameter("@Position", SqlDbType.Int,4),
					new SqlParameter("@Memo", SqlDbType.NVarChar,500),
					new SqlParameter("@Company", SqlDbType.Int,4),
					new SqlParameter("@IsDisabled", SqlDbType.Int,4),
					new SqlParameter("@MobileTel", SqlDbType.NVarChar,50),
					new SqlParameter("@QQ", SqlDbType.NVarChar,50),
					new SqlParameter("@Email", SqlDbType.NVarChar,50),
					new SqlParameter("@Reviser", SqlDbType.NVarChar,50),
					new SqlParameter("@ReviseDate", SqlDbType.DateTime),
					new SqlParameter("@Education", SqlDbType.NVarChar,50),
					new SqlParameter("@School", SqlDbType.NVarChar,50),
					new SqlParameter("@Political", SqlDbType.NVarChar,50),
					new SqlParameter("@FamilyAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@PresentAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@HomePhone", SqlDbType.NVarChar,50),
					new SqlParameter("@EducationalBackground", SqlDbType.NVarChar),
					new SqlParameter("@FamilyMember", SqlDbType.NVarChar),
					new SqlParameter("@WorkExperience", SqlDbType.NVarChar),
					new SqlParameter("@Memo1", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo2", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo3", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo4", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo5", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo6", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo7", SqlDbType.NVarChar,100),
					new SqlParameter("@Memo8", SqlDbType.NVarChar,100),
					new SqlParameter("@EmployeeID", SqlDbType.NVarChar,50)};
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Sex;
            parameters[2].Value = model.EmployeeImage;
            parameters[3].Value = model.Birthday;
            parameters[4].Value = model.IdentityCard;
            parameters[5].Value = model.IdentityCardImage;
            parameters[6].Value = model.Class;
            parameters[7].Value = model.Position;
            parameters[8].Value = model.Memo;
            parameters[9].Value = model.Company;
            parameters[10].Value = model.IsDisabled;
            parameters[11].Value = model.MobileTel;
            parameters[12].Value = model.QQ;
            parameters[13].Value = model.Email;
            parameters[14].Value = model.Reviser;
            parameters[15].Value = model.ReviseDate;
            parameters[16].Value = model.Education;
            parameters[17].Value = model.School;
            parameters[18].Value = model.Political;
            parameters[19].Value = model.FamilyAddress;
            parameters[20].Value = model.PresentAddress;
            parameters[21].Value = model.HomePhone;
            parameters[22].Value = model.EducationalBackground;
            parameters[23].Value = model.FamilyMember;
            parameters[24].Value = model.WorkExperience;
            parameters[25].Value = model.Memo1;
            parameters[26].Value = model.Memo2;
            parameters[27].Value = model.Memo3;
            parameters[28].Value = model.Memo4;
            parameters[29].Value = model.Memo5;
            parameters[30].Value = model.Memo6;
            parameters[31].Value = model.Memo7;
            parameters[32].Value = model.Memo8;
            parameters[33].Value = model.EmployeeID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string EmployeeID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_CF_OA_Employee ");
            strSql.Append(" where EmployeeID=@EmployeeID ");
            SqlParameter[] parameters = {
					new SqlParameter("@EmployeeID", SqlDbType.NVarChar,50)			};
            parameters[0].Value = EmployeeID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string EmployeeIDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_CF_OA_Employee ");
            strSql.Append(" where EmployeeID in (" + EmployeeIDlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WISD.CarFriend.Model.CFModel.T_CF_OA_Employee GetModel(string EmployeeID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 EmployeeID,Name,Sex,EmployeeImage,Birthday,IdentityCard,IdentityCardImage,Class,Position,Memo,Company,IsDisabled,MobileTel,QQ,Email,Reviser,ReviseDate,Education,School,Political,FamilyAddress,PresentAddress,HomePhone,EducationalBackground,FamilyMember,WorkExperience,Memo1,Memo2,Memo3,Memo4,Memo5,Memo6,Memo7,Memo8 from T_CF_OA_Employee ");
            strSql.Append(" where EmployeeID=@EmployeeID ");
            SqlParameter[] parameters = {
					new SqlParameter("@EmployeeID", SqlDbType.NVarChar,50)			};
            parameters[0].Value = EmployeeID;

            WISD.CarFriend.Model.CFModel.T_CF_OA_Employee model = new WISD.CarFriend.Model.CFModel.T_CF_OA_Employee();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["EmployeeID"] != null && ds.Tables[0].Rows[0]["EmployeeID"].ToString() != "")
                {
                    model.EmployeeID = ds.Tables[0].Rows[0]["EmployeeID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Sex"] != null && ds.Tables[0].Rows[0]["Sex"].ToString() != "")
                {
                    model.Sex = int.Parse(ds.Tables[0].Rows[0]["Sex"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EmployeeImage"] != null && ds.Tables[0].Rows[0]["EmployeeImage"].ToString() != "")
                {
                    model.EmployeeImage = ds.Tables[0].Rows[0]["EmployeeImage"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Birthday"] != null && ds.Tables[0].Rows[0]["Birthday"].ToString() != "")
                {
                    model.Birthday = DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IdentityCard"] != null && ds.Tables[0].Rows[0]["IdentityCard"].ToString() != "")
                {
                    model.IdentityCard = ds.Tables[0].Rows[0]["IdentityCard"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IdentityCardImage"] != null && ds.Tables[0].Rows[0]["IdentityCardImage"].ToString() != "")
                {
                    model.IdentityCardImage = ds.Tables[0].Rows[0]["IdentityCardImage"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Class"] != null && ds.Tables[0].Rows[0]["Class"].ToString() != "")
                {
                    model.Class = int.Parse(ds.Tables[0].Rows[0]["Class"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Position"] != null && ds.Tables[0].Rows[0]["Position"].ToString() != "")
                {
                    model.Position = int.Parse(ds.Tables[0].Rows[0]["Position"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Memo"] != null && ds.Tables[0].Rows[0]["Memo"].ToString() != "")
                {
                    model.Memo = ds.Tables[0].Rows[0]["Memo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Company"] != null && ds.Tables[0].Rows[0]["Company"].ToString() != "")
                {
                    model.Company = int.Parse(ds.Tables[0].Rows[0]["Company"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsDisabled"] != null && ds.Tables[0].Rows[0]["IsDisabled"].ToString() != "")
                {
                    model.IsDisabled = int.Parse(ds.Tables[0].Rows[0]["IsDisabled"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MobileTel"] != null && ds.Tables[0].Rows[0]["MobileTel"].ToString() != "")
                {
                    model.MobileTel = ds.Tables[0].Rows[0]["MobileTel"].ToString();
                }
                if (ds.Tables[0].Rows[0]["QQ"] != null && ds.Tables[0].Rows[0]["QQ"].ToString() != "")
                {
                    model.QQ = ds.Tables[0].Rows[0]["QQ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Email"] != null && ds.Tables[0].Rows[0]["Email"].ToString() != "")
                {
                    model.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Reviser"] != null && ds.Tables[0].Rows[0]["Reviser"].ToString() != "")
                {
                    model.Reviser = ds.Tables[0].Rows[0]["Reviser"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ReviseDate"] != null && ds.Tables[0].Rows[0]["ReviseDate"].ToString() != "")
                {
                    model.ReviseDate = DateTime.Parse(ds.Tables[0].Rows[0]["ReviseDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Education"] != null && ds.Tables[0].Rows[0]["Education"].ToString() != "")
                {
                    model.Education = ds.Tables[0].Rows[0]["Education"].ToString();
                }
                if (ds.Tables[0].Rows[0]["School"] != null && ds.Tables[0].Rows[0]["School"].ToString() != "")
                {
                    model.School = ds.Tables[0].Rows[0]["School"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Political"] != null && ds.Tables[0].Rows[0]["Political"].ToString() != "")
                {
                    model.Political = ds.Tables[0].Rows[0]["Political"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FamilyAddress"] != null && ds.Tables[0].Rows[0]["FamilyAddress"].ToString() != "")
                {
                    model.FamilyAddress = ds.Tables[0].Rows[0]["FamilyAddress"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PresentAddress"] != null && ds.Tables[0].Rows[0]["PresentAddress"].ToString() != "")
                {
                    model.PresentAddress = ds.Tables[0].Rows[0]["PresentAddress"].ToString();
                }
                if (ds.Tables[0].Rows[0]["HomePhone"] != null && ds.Tables[0].Rows[0]["HomePhone"].ToString() != "")
                {
                    model.HomePhone = ds.Tables[0].Rows[0]["HomePhone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EducationalBackground"] != null && ds.Tables[0].Rows[0]["EducationalBackground"].ToString() != "")
                {
                    model.EducationalBackground = ds.Tables[0].Rows[0]["EducationalBackground"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FamilyMember"] != null && ds.Tables[0].Rows[0]["FamilyMember"].ToString() != "")
                {
                    model.FamilyMember = ds.Tables[0].Rows[0]["FamilyMember"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WorkExperience"] != null && ds.Tables[0].Rows[0]["WorkExperience"].ToString() != "")
                {
                    model.WorkExperience = ds.Tables[0].Rows[0]["WorkExperience"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo1"] != null && ds.Tables[0].Rows[0]["Memo1"].ToString() != "")
                {
                    model.Memo1 = ds.Tables[0].Rows[0]["Memo1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo2"] != null && ds.Tables[0].Rows[0]["Memo2"].ToString() != "")
                {
                    model.Memo2 = ds.Tables[0].Rows[0]["Memo2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo3"] != null && ds.Tables[0].Rows[0]["Memo3"].ToString() != "")
                {
                    model.Memo3 = ds.Tables[0].Rows[0]["Memo3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo4"] != null && ds.Tables[0].Rows[0]["Memo4"].ToString() != "")
                {
                    model.Memo4 = ds.Tables[0].Rows[0]["Memo4"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo5"] != null && ds.Tables[0].Rows[0]["Memo5"].ToString() != "")
                {
                    model.Memo5 = ds.Tables[0].Rows[0]["Memo5"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo6"] != null && ds.Tables[0].Rows[0]["Memo6"].ToString() != "")
                {
                    model.Memo6 = ds.Tables[0].Rows[0]["Memo6"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo7"] != null && ds.Tables[0].Rows[0]["Memo7"].ToString() != "")
                {
                    model.Memo7 = ds.Tables[0].Rows[0]["Memo7"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Memo8"] != null && ds.Tables[0].Rows[0]["Memo8"].ToString() != "")
                {
                    model.Memo8 = ds.Tables[0].Rows[0]["Memo8"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select EmployeeID,Name,Sex,EmployeeImage,Birthday,IdentityCard,IdentityCardImage,Class,Position,Memo,Company,IsDisabled,MobileTel,QQ,Email,Reviser,ReviseDate,Education,School,Political,FamilyAddress,PresentAddress,HomePhone,EducationalBackground,FamilyMember,WorkExperience,Memo1,Memo2,Memo3,Memo4,Memo5,Memo6,Memo7,Memo8 ");
            strSql.Append(" FROM T_CF_OA_Employee ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }


        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" EmployeeID,Name,Sex,EmployeeImage,Birthday,IdentityCard,IdentityCardImage,Class,Position,Memo,Company,IsDisabled,MobileTel,QQ,Email,Reviser,ReviseDate,Education,School,Political,FamilyAddress,PresentAddress,HomePhone,EducationalBackground,FamilyMember,WorkExperience,Memo1,Memo2,Memo3,Memo4,Memo5,Memo6,Memo7,Memo8 ");
            strSql.Append(" FROM T_CF_OA_Employee ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }


        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM T_CF_OA_Employee ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }


        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.EmployeeID desc");
            }
            strSql.Append(")AS Row, T.*  from T_CF_OA_Employee T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }


        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "T_CF_OA_Employee";
            parameters[1].Value = "EmployeeID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion


        #region SelfCode
       
        #endregion

    }
}
